package com.leyou.trade.dto;


import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.leyou.common.dto.BaseDTO;
import com.leyou.common.entity.BaseEntity;
import com.leyou.trade.entity.OrderDetail;

import java.util.*;
import java.util.stream.Collectors;

public class OrderListDTO extends BaseDTO {

    private Date createTime;

    @JsonSerialize(using = ToStringSerializer.class)
    private Long orderId;
    /**
     * 邮费
     */
    private Long postFee;
    /**
     * 实付金额
     */
    private Long actualFee;

    /**
     * 订单状态,1、未付款 2、已付款,未发货 3、已发货,未确认 4、确认收货，交易成功 5、交易取消，订单关闭 6、交易结束
     */
    private Integer status;

    @TableField()
    private List<OrderDetailDTO> orderDetails;

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public Long getPostFee() {
        return postFee;
    }

    public void setPostFee(Long postFee) {
        this.postFee = postFee;
    }

    public Long getActualFee() {
        return actualFee;
    }

    public void setActualFee(Long actualFee) {
        this.actualFee = actualFee;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public List<OrderDetailDTO> getOrderDetails() {
        return orderDetails;
    }

    public void setOrderDetails(List<OrderDetailDTO> orderDetails) {
        this.orderDetails = orderDetails;
    }

    public OrderListDTO(BaseEntity entity) {
        super(entity);
    }

    public static <T extends BaseEntity> List<OrderListDTO> convertEntityList(Collection<T> list) {
        if (list == null) return Collections.emptyList();
        return list.stream().map(OrderListDTO::new).collect(Collectors.toList());
    }


}
